#ifndef CUSTOMHEADERVIEW_H
#define CUSTOMHEADERVIEW_H

#include <QObject>
#include <QWidget>
#include <QHeaderView>
#include <memory.h>
#include <iostream>
#include <QMutex>

class CustomHeaderView : public QHeaderView
{
public:
    explicit CustomHeaderView(Qt::Orientation orientation, QWidget *parent = nullptr);

    void removeCurColumn();
    void addColumn(int pos,const QString& title);
    void setHeaderItemLabel(int pos,const QString& content);
    // QWidget interface
protected:
    void dragEnterEvent(QDragEnterEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void dropEvent(QDropEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    // QHeaderView interface
protected:
    void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;

private:
    QPoint m_mousePressPoint;
    int m_curDragCol;
    bool mb_pressed;


    QMutex m_dragMutex;
    // QAbstractItemView interface
protected:
    void startDrag(Qt::DropActions supportedActions);

};

#endif // CUSTOMHEADERVIEW_H
